package com.example.wanbaqian.activity;

import android.os.Bundle;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.view.View;

import com.example.wanbaqian.R;
import com.example.wanbaqian.adapter.FragmentAdapter;
import com.example.wanbaqian.base.BaseActivity;
import com.example.wanbaqian.fragment.FindActivityFragment;
import com.example.wanbaqian.fragment.FindMessageFragment;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;

/**
 * 我的消息界面
 */
public class FindMessageActivity extends BaseActivity {

    @BindView(R.id.tabLayout)
    TabLayout tabLayout;
    @BindView(R.id.viewPager)
    ViewPager viewPager;
    List<Fragment> fragmentList = new ArrayList<>();
    String[] titles = {"热门活动", "消息公告"};
    FragmentAdapter adapter;
    @Override
    protected int getLayout() {
        return R.layout.activity_findmessage;
    }

    @Override
    protected void initView(Bundle savedInstanceState) {
        setStatusBarColor(R.color.main_color);
        setToolBar("我的消息");
        mToolbar.setNavigationOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
    }

    @Override
    protected void initDate() {
        fragmentList.clear();
        fragmentList.add(FindActivityFragment.newInstance(titles[0]));
        fragmentList.add(FindMessageFragment.newInstance(titles[1]));
        if (adapter == null) {
            adapter = new FragmentAdapter(getSupportFragmentManager(), fragmentList, titles);
        }
        viewPager.setAdapter(adapter);
        viewPager.setOffscreenPageLimit(1);
        tabLayout.setupWithViewPager(viewPager);
    }


}
